package pers.lonestar.framework.utils.support.converters;

import java.math.BigDecimal;

import pers.lonestar.framework.utils.support.enums.CellDataTypeEnum;
import pers.lonestar.framework.utils.support.metadata.CellData;

public class DoubleConverter implements Converter<Double> {
    @Override
    public Double convertToJavaObject(CellData<Double> cellData) {
        return cellData.getNumberValue().doubleValue();
    }

    @Override
    public CellData<Double> convertToCellData(Double data) {
        CellData<Double> cellData = new CellData<>();
        cellData.setNumberValue(BigDecimal.valueOf(data));
        cellData.setType(CellDataTypeEnum.NUMBER);
        cellData.setData(data);
        return cellData;
    }
}
